package com.ruoyi.loan.vo;

import com.ruoyi.loan.constant.ExamineStatus;
import com.ruoyi.loan.constant.PoorGrade;
import com.ruoyi.loan.constant.PoorType;
import lombok.Data;

import java.sql.Timestamp;
import java.util.Date;

/**
 * @Author lin
 * @Date 2022/4/5 2:02
 */
@Data
public class SelectLoanVo {

    private Integer loanId;

    private Integer userId;

    private String username;

    private String gender;

    private String phone;

    private String mail;

    private String major;

    private String college;

    private Integer grade;

    private Integer classNo;

    private String idCard;

    private Integer type;

    private String poorType;

    /**
     * 贷款金额
     */
    private Integer amount;

    /**
     * 贷款原因
     */
    private String reasons;

    /**
     * 贷款年限
     */
    private Integer loanYears;

    /**
     * 代还款金额
     */
    private Integer owingAmount;

    /**
     * 回访录音路径
     */
    private String visitVoicePath;

    /**
     * 申请状态
     */
    private Integer status;
    private String state;

    /**
     * 逾期状态
     */
    private String overdue;

    /**
     * 驳回原因
     */
    private String refuseReasons;

    /**
     * 审核时间
     */
    private Timestamp adminTime;

    /**
     * 创建时间
     */
    private Timestamp createTime;

    /**
     * 修改时间
     */
    private Timestamp updateTime;

    public void setStatus(Integer status) {
        this.status = status;
        if (status.equals(ExamineStatus.FAILED.getCode())){
            this.state = ExamineStatus.FAILED.getMessage();
        }else if (status.equals(ExamineStatus.SUCCESS.getCode())){
            this.state = ExamineStatus.SUCCESS.getMessage();
        }else if (status.equals(ExamineStatus.UPLOAD.getCode())){
            this.state = ExamineStatus.UPLOAD.getMessage();
        }else{
            this.state = ExamineStatus.EXAMINE.getMessage();
        }
    }

    public void setType(Integer type) {
        this.type = type;
        if (type.equals(PoorGrade.NO_POOR.getCode())){
            this.poorType = PoorGrade.NO_POOR.getMessage();
        }else if (type.equals(PoorGrade.COMMONLY_POOR.getCode())){
            this.poorType = PoorGrade.COMMONLY_POOR.getMessage();
        }else {
            this.poorType = PoorGrade.SPECIAL_POOR.getMessage();
        }
    }
}
